﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using ExtAspNet;

public partial class Module_CustManger_CustSearchCondition : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button2.OnClientClick = ActiveWindow.GetHideReference();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //拼装查找条件,并且刷新父亲页面
        //名称
        string Sqlwhere = " and  1=1 ";
        if (!string.IsNullOrEmpty(CustName.Text))
        {
            switch (DropDownList1.SelectedItem.Value)
            {
                case "等于":
                    Sqlwhere += " and CustName='" + CustName .Text+ "'";
                    break;
                case "不等于":
                    Sqlwhere += " and CustName<>'" + CustName.Text + "'";
                    break;
                case "包含":
                    Sqlwhere += " and CustName like '%" + CustName.Text + "%'";
                    break;    
                default:
                    Sqlwhere += "";
                    break;
            }
        }

        //拼接客户电话

        if (!string .IsNullOrEmpty(CustTel.Text))
        {
            switch (DropDownList2.SelectedItem.Value)
            {
                case "等于":
                    Sqlwhere += " and TelPhone='" + CustTel.Text + "' ";
                    break;
                case "不等于":
                    Sqlwhere += " and TelPhone<>'" + CustTel.Text + "' ";
                    break;
                case "包含":
                    Sqlwhere += " and TelPhone like '%" + CustTel.Text + "%' ";
                    break;
                default:
                    Sqlwhere += "";
                    break;
            }
        }

       
        //拼接Creatime

        if (DatePicker1.SelectedDate!=null)
        {
            switch (DropDownList5.SelectedItem.Value)
            {

                case "等于":
                    Sqlwhere += " and Creatime like '%" + DatePicker1.SelectedDate.ToString() + "%' ";
                    break;
                case "小于":
                    Sqlwhere += " and Creatime<'" + DatePicker1.SelectedDate.ToString() + "' ";
                    break;
                case "大于":
                    Sqlwhere += " and Creatime>'" + DatePicker1.SelectedDate.ToString() + "' ";
                    break;
                default:
                    Sqlwhere += "";
                    break;
            }
        }
        PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(Sqlwhere) + ActiveWindow.GetHidePostBackReference());
    }
}